class ManageController < ApplicationController
  layout "manage", :except => "show_user_todos"
  
  before_filter :authorize_manager, :except =>"index"
  
  def index
    session[:date] = Date.today if !session[:date] || params[:today]
	if params[:move]
		case params[:move].to_i
		when 0
			session[:date] = params[:seldate].to_date 
		else
			session[:date] = session[:date] + params[:move].to_i
		end  
	end	
	@user = User.find_by_id(session[:user_id])
	if @user.has_role?('admin')  	
    	@all_users = User.find(:all)
	else
		@all_users = Role.find_by_name("user").users
	end
  end
  
  def show_user_todos  	  	
 			@user = User.find_by_id(params[:id])
	   	@todos = Todo.find_todos_for_me(@user.id, :date => session[:date])
	   	@expires = @user.find_expired_todos		
  end
end
